package com.ybzl.collect.protocol;

import com.ybzl.collect.webservice.service.IUserInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import java.net.URL;

public class WebserviceProtocol {

    private static final Logger logger = LoggerFactory.getLogger(WebserviceProtocol.class);

    /**
     * 基于jar的形式调用wenservice
     */
    private static void doWithJar() {
        try {
            // 创建wsdl的url
            URL url = new URL("http://127.0.0.1:7001/webServices11/userInfoService?wsdl");
            // 指定命名空间和服务名称
            QName qName = new QName("http://server.webservice.gtp.sinotrans.com", "userInfoService");
            Service service = Service.create(url, qName);
            // 通过getPort方法返回指定接口
            IUserInfoService myServer = service.getPort(IUserInfoService.class);
            System.out.println(myServer.getUserInfoById(1L));
        } catch (Exception w) {
            logger.error("e:{}", w.getMessage(), w);
        }

    }
}
